package com;

import com.sun.javafx.tools.packager.PackagerException;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class TimeTest {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个时间");
        String time1 = sc.next();
        System.out.println("再输入一个时间");
        SimpleDateFormat sd1 = new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
        String time2 = sc.next();

        try {
            Date date1 = sd1.parse(time1);
            Date date2 = sd1.parse(time2);
            long day1 = date1.getTime();
            long day2 = date2.getTime();
            long days = Math.abs(day1 - day2);
            System.out.println("相差的天数=" + Math.ceil(days/(1000*60*60*24)) + "天");

        } catch ( Exception e){
            e.printStackTrace();
        }



    }
}
